ARM U-Boot heap updates
PATCH 1/1 ARM U-Boot heap updates
Again, patch is against http://bzr.savannah.gnu.org/r/grub/branches/arm
- Increases heap size to 8MB.
- Moves heap from after the stack in memory to before the stack, in order to be able to grow into the modules region post load.
=== modified file 'grub-core/kern/arm/uboot/startup.S'
kern/arm/uboot/startup.S +6 -4
@@ -43,8 +43,8 @@ * Any part of the module blob that extends beyond _end. * <modules>: * Loadable modules, post relocation. + * <heap>: * <stack>: - * <heap>: */ .text
@@ -85,10 +85,12 @@ subs r2, #4 @ remaining -= 4 bne 1b @ while remaining != 0 - @ Set up a new stack, beyond the end of copied modules. + @ Set up a new stack, beyond the end of heap. + ldr r2, =GRUB_KERNEL_MACHINE_HEAP_SIZE ldr r3, =GRUB_KERNEL_MACHINE_STACK_SIZE - add r3, r1, r3 @ Place stack beyond end of modules - and sp, r3, #~0x7 @ Ensure 8-byte alignment + add r3, r3, r2 + add r3, r1, r3 @ Place stack beyond end of heap + bic sp, r3, #0x7 @ Ensure 8-byte alignment @ Since we _are_ the C run-time, we need to manually zero the BSS @ region before continuing
=== modified file 'grub-core/kern/uboot/hw.c'
kern/uboot/hw.c +2 -3
@@ -33,15 +33,14 @@* grub_uboot_probe_memory(): * Queries U-Boot for available memory regions. * -* Sets up heap near the image in memory and sets up "start_of_ram". +* Sets up heap beyond the modules area in memory and sets up "start_of_ram". */ void grub_uboot_mm_init (void ) {struct sys_info *si =grub_uboot_get_sys_info (); -grub_mm_init_region ((void *) (grub_modules_get_end () - +GRUB_KERNEL_MACHINE_STACK_SIZE ), +grub_mm_init_region ((void *)grub_modules_get_end (),GRUB_KERNEL_MACHINE_HEAP_SIZE );if (si && (si->mr_no !=0 ))
=== modified file 'include/grub/arm/uboot/kernel.h'
grub/arm/uboot/kernel.h +1 -1
@@ -27,6 +27,6 @@#endif /* ! ASM_FILE */ #define GRUB_KERNEL_MACHINE_STACK_SIZE 0x40000 -#define GRUB_KERNEL_MACHINE_HEAP_SIZE (grub_size_t) (2 * 1024 * 1024) +#define GRUB_KERNEL_MACHINE_HEAP_SIZE (8 * 1024 * 1024)#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
Quoted 6 lines · Leif Lindholm
Again, patch is against http://bzr.savannah.gnu.org/r/grub/branches/arm
- Increases heap size to 8MB.
- Moves heap from after the stack in memory to before the stack, in order to be able to grow into the modules region post load.
Why not use the order:
<core><stack><modules><heap>
This would allow setting the size of heap in function of available RAM, rather than hardcodding its size.