From: Vladimir 'phcoder' Serbinenko Date: Tue, 21 Sep 2010 22:53:34 +0000 (+0200) Subject: Fix bugs in asm code X-Git-Tag: 1.99~425^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9a0e5c815e76c48141d1e126682b1473036be669;p=thirdparty%2Fgrub.git Fix bugs in asm code --- diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index d810f2fb4..c41ce8257 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -67,10 +67,11 @@ argcont: #define DO_PARSE(str, reg) \ addiu $t2, $s0, (str-base);\ bal parsestr;\ + nop ;\ beq $v0, $zero, 1f;\ nop ;\ b 2f;\ - move reg, $v0; + move reg, $v0; \ 1: DO_PARSE (busclockstr, $s2) DO_PARSE (cpuclockstr, $s3) @@ -169,10 +170,10 @@ argdone: */ move $s6, $a3 - lui $sp, %hi(_start) + lui $sp, %hi(_start - 256) bal EXT_C(grub_decompress_core) - addiu $sp, $sp, %lo(_start) + addiu $sp, $sp, %lo(_start - 256) move $a0, $s1 move $a1, $s6 diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S index 97145b818..ae0e0b187 100644 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@ -35,6 +35,10 @@ start: bal cont nop + . = _start + GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE +total_module_size: + .long 0 + . = _start + GRUB_KERNEL_MACHINE_PREFIX VARIABLE(grub_prefix) @@ -70,13 +74,13 @@ cont: #endif /* Move the modules out of BSS. */ - lui $t2, %hi(_end) - addiu $t2, %lo(_end) + lui $t2, %hi(__bss_start) + addiu $t2, %lo(__bss_start) lui $t1, %hi(_end) addiu $t1, %lo(_end) - addiu $t1, (GRUB_KERNEL_MACHINE_MOD_ALIGN-1) - li $t3, (GRUB_KERNEL_MACHINE_MOD_ALIGN-1) + addiu $t1, (GRUB_KERNEL_MACHINE_MOD_ALIGN - 1) + li $t3, (GRUB_KERNEL_MACHINE_MOD_ALIGN - 1) nor $t3, $t3, $0 and $t1, $t1, $t3 @@ -85,29 +89,33 @@ cont: /* Backward copy. */ add $t1, $t1, $t3 add $t2, $t2, $t3 - addiu $t1, $t1, 0xffff - addiu $t2, $t2, 0xffff + addiu $t1, $t1, -1 + addiu $t2, $t2, -1 /* $t2 is source. $t1 is destination. $t3 is size. */ modulesmovcont: + beq $t3, $0, modulesmovdone + nop lb $t4, 0($t2) sb $t4, 0($t1) + addiu $t2, $t2, -1 addiu $t1, $t1, -1 - addiu $t3, $t3, -1 - bne $t3, $0, modulesmovcont - addiu $t2, $t2, -1 - + b modulesmovcont + addiu $t3, $t3, -1 +modulesmovdone: + /* Clean BSS. */ lui $t1, %hi(__bss_start) - addiu $t1, %lo(__bss_start) + addiu $t1, $t1, %lo(__bss_start) lui $t2, %hi(_end) - addiu $t2, %lo(_end) + addiu $t2, $t2, %lo(_end) bsscont: sb $0,0($t1) + addiu $t1, $t1, 1 sltu $t3, $t1, $t2 bne $t3, $0, bsscont - addiu $t1, $t1, 1 + nop lui $t1, %hi(grub_main) addiu $t1, %lo(grub_main)