Fix bugs in asm code

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-22 00:53:34 +02:00
parent 67c4bb722d
commit 9a0e5c815e
2 changed files with 25 additions and 16 deletions

View file

@ -67,10 +67,11 @@ argcont:
#define DO_PARSE(str, reg) \ #define DO_PARSE(str, reg) \
addiu $t2, $s0, (str-base);\ addiu $t2, $s0, (str-base);\
bal parsestr;\ bal parsestr;\
nop ;\
beq $v0, $zero, 1f;\ beq $v0, $zero, 1f;\
nop ;\ nop ;\
b 2f;\ b 2f;\
move reg, $v0; move reg, $v0; \
1: 1:
DO_PARSE (busclockstr, $s2) DO_PARSE (busclockstr, $s2)
DO_PARSE (cpuclockstr, $s3) DO_PARSE (cpuclockstr, $s3)
@ -169,10 +170,10 @@ argdone:
*/ */
move $s6, $a3 move $s6, $a3
lui $sp, %hi(_start) lui $sp, %hi(_start - 256)
bal EXT_C(grub_decompress_core) bal EXT_C(grub_decompress_core)
addiu $sp, $sp, %lo(_start) addiu $sp, $sp, %lo(_start - 256)
move $a0, $s1 move $a0, $s1
move $a1, $s6 move $a1, $s6

View file

@ -35,6 +35,10 @@ start:
bal cont bal cont
nop nop
. = _start + GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE
total_module_size:
.long 0
. = _start + GRUB_KERNEL_MACHINE_PREFIX . = _start + GRUB_KERNEL_MACHINE_PREFIX
VARIABLE(grub_prefix) VARIABLE(grub_prefix)
@ -70,13 +74,13 @@ cont:
#endif #endif
/* Move the modules out of BSS. */ /* Move the modules out of BSS. */
lui $t2, %hi(_end) lui $t2, %hi(__bss_start)
addiu $t2, %lo(_end) addiu $t2, %lo(__bss_start)
lui $t1, %hi(_end) lui $t1, %hi(_end)
addiu $t1, %lo(_end) addiu $t1, %lo(_end)
addiu $t1, (GRUB_KERNEL_MACHINE_MOD_ALIGN-1) addiu $t1, (GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
li $t3, (GRUB_KERNEL_MACHINE_MOD_ALIGN-1) li $t3, (GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
nor $t3, $t3, $0 nor $t3, $t3, $0
and $t1, $t1, $t3 and $t1, $t1, $t3
@ -85,29 +89,33 @@ cont:
/* Backward copy. */ /* Backward copy. */
add $t1, $t1, $t3 add $t1, $t1, $t3
add $t2, $t2, $t3 add $t2, $t2, $t3
addiu $t1, $t1, 0xffff addiu $t1, $t1, -1
addiu $t2, $t2, 0xffff addiu $t2, $t2, -1
/* $t2 is source. $t1 is destination. $t3 is size. */ /* $t2 is source. $t1 is destination. $t3 is size. */
modulesmovcont: modulesmovcont:
beq $t3, $0, modulesmovdone
nop
lb $t4, 0($t2) lb $t4, 0($t2)
sb $t4, 0($t1) sb $t4, 0($t1)
addiu $t2, $t2, -1
addiu $t1, $t1, -1 addiu $t1, $t1, -1
addiu $t3, $t3, -1 b modulesmovcont
bne $t3, $0, modulesmovcont addiu $t3, $t3, -1
addiu $t2, $t2, -1 modulesmovdone:
/* Clean BSS. */ /* Clean BSS. */
lui $t1, %hi(__bss_start) lui $t1, %hi(__bss_start)
addiu $t1, %lo(__bss_start) addiu $t1, $t1, %lo(__bss_start)
lui $t2, %hi(_end) lui $t2, %hi(_end)
addiu $t2, %lo(_end) addiu $t2, $t2, %lo(_end)
bsscont: bsscont:
sb $0,0($t1) sb $0,0($t1)
addiu $t1, $t1, 1
sltu $t3, $t1, $t2 sltu $t3, $t1, $t2
bne $t3, $0, bsscont bne $t3, $0, bsscont
addiu $t1, $t1, 1 nop
lui $t1, %hi(grub_main) lui $t1, %hi(grub_main)
addiu $t1, %lo(grub_main) addiu $t1, %lo(grub_main)