Startup code cleanup

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2009-12-06 15:32:32 +01:00
parent bef393d4b3
commit a22078eb4f
2 changed files with 44 additions and 34 deletions

View file

@ -42,27 +42,55 @@ kernel_image_size:
.long 0 .long 0
codestart: codestart:
/* Decompress the payload. */ /* Decompress the payload. */
move $t9, $ra move $s0, $ra
addiu $t2, $t9, GRUB_KERNEL_CPU_RAW_SIZE - BASE_ADDR addiu $a0, $s0, GRUB_KERNEL_CPU_RAW_SIZE - BASE_ADDR
lui $t1, %hi(compressed) lui $a1, %hi(compressed)
addiu $t1, %lo(compressed) addiu $a1, %lo(compressed)
lw $t3, (GRUB_KERNEL_CPU_COMPRESSED_SIZE - BASE_ADDR)($t9) lw $a2, (GRUB_KERNEL_CPU_COMPRESSED_SIZE - BASE_ADDR)($s0)
move $s1, $a1
/* $t2 contains source compressed address, $t1 is destination, /* $a0 contains source compressed address, $a1 is destination,
$t3 is compressed size. FIXME: put LZMA here. Don't clober $t9 $a2 is compressed size. FIXME: put LZMA here. Don't clober $s0, $s1.
On return $v0 contains uncompressed size.
*/ */
move $v0, $a2
reloccont: reloccont:
lb $t4, 0($t2) lb $t4, 0($a0)
sb $t4, 0($t1) sb $t4, 0($a1)
addiu $t1,$t1,1 addiu $a1,$a1,1
addiu $t2,$t2,1 addiu $a0,$a0,1
addiu $t3, 0xffff addiu $a2, 0xffff
bne $t3, $0, reloccont bne $a2, $0, reloccont
move $a0, $s1
move $a1, $v0
#include "cache_flush.S"
lui $t1, %hi(cont)
addiu $t1, %lo(cont)
jr $t1
. = _start + GRUB_KERNEL_CPU_RAW_SIZE
compressed:
. = _start + GRUB_KERNEL_CPU_PREFIX
VARIABLE(grub_prefix)
/* to be filled by grub-mkelfimage */
/*
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_CPU_DATA_END
cont:
/* Move the modules out of BSS. */ /* Move the modules out of BSS. */
lui $t1, %hi(_start) lui $t1, %hi(_start)
addiu $t1, %lo(_start) addiu $t1, %lo(_start)
lw $t2, (GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE - BASE_ADDR)($t9) lw $t2, (GRUB_KERNEL_CPU_KERNEL_IMAGE_SIZE - BASE_ADDR)($s0)
addu $t2, $t1, $t2 addu $t2, $t1, $t2
lui $t1, %hi(_end) lui $t1, %hi(_end)
@ -72,7 +100,7 @@ reloccont:
nor $t3, $t3, $0 nor $t3, $t3, $0
and $t1, $t1, $t3 and $t1, $t1, $t3
lw $t3, (GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE - BASE_ADDR)($t9) lw $t3, (GRUB_KERNEL_CPU_TOTAL_MODULE_SIZE - BASE_ADDR)($s0)
/* Backward copy. */ /* Backward copy. */
add $t1, $t1, $t3 add $t1, $t1, $t3
@ -105,20 +133,5 @@ bsscont:
lui $t1, %hi(grub_main) lui $t1, %hi(grub_main)
addiu $t1, %lo(grub_main) addiu $t1, %lo(grub_main)
#if __mips >= 2
sync
#endif
jr $t1 jr $t1
. = _start + GRUB_KERNEL_CPU_RAW_SIZE
compressed:
. = _start + GRUB_KERNEL_CPU_PREFIX
VARIABLE(grub_prefix)
/* to be filled by grub-mkelfimage */
/*
* Leave some breathing room for the prefix.
*/
. = _start + GRUB_KERNEL_CPU_DATA_END

View file

@ -363,10 +363,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X); phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
target_addr = ALIGN_UP (GRUB_KERNEL_MACHINE_LINK_ADDR target_addr = ALIGN_UP (GRUB_KERNEL_MACHINE_LINK_ADDR
+ kernel_size + total_module_size + kernel_size + total_module_size, 32);
+ 0x100000
// + BSS_SIZE
, 32);
ehdr->e_entry = grub_host_to_target32 (target_addr); ehdr->e_entry = grub_host_to_target32 (target_addr);
phdr->p_vaddr = grub_host_to_target32 (target_addr); phdr->p_vaddr = grub_host_to_target32 (target_addr);
phdr->p_paddr = grub_host_to_target32 (target_addr); phdr->p_paddr = grub_host_to_target32 (target_addr);