From 285540e44869f7d463eb97e56141f6c19c2af67d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 10 Oct 2015 10:34:55 +0200 Subject: [PATCH] mips: Make the assembly-code N32-compatible. There are no $t4 or $t5 in N32 but there are $a4 and $a5. --- asm-tests/mips.S | 4 ++-- grub-core/boot/mips/startup_raw.S | 37 ++++++++++++++++--------------- grub-core/kern/mips/startup.S | 5 +++-- include/grub/mips/asm.h | 11 +++++++++ 4 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 include/grub/mips/asm.h diff --git a/asm-tests/mips.S b/asm-tests/mips.S index 8233dfcc9..1312d47d5 100644 --- a/asm-tests/mips.S +++ b/asm-tests/mips.S @@ -4,8 +4,8 @@ .set mips3 sync - ld $t2, 0($t6) + ld $t2, 0($t1) a: - addiu $t7, $s0, (b - a) + addiu $t1, $s0, (b - a) b: nop diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index ca3413bbe..6a81b3733 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -22,6 +22,7 @@ #include #include #include +#include #define BASE_ADDR 8 @@ -118,32 +119,32 @@ parsestr: move $v0, $zero move $t3, $t1 3: - lb $t4, 0($t2) - lb $t5, 0($t3) + lb GRUB_ASM_T4, 0($t2) + lb GRUB_ASM_T5, 0($t3) addiu $t2, $t2, 1 addiu $t3, $t3, 1 - beq $t5, $zero, 1f + beq GRUB_ASM_T5, $zero, 1f nop - beq $t5, $t4, 3b + beq GRUB_ASM_T5, GRUB_ASM_T4, 3b nop - bne $t4, $zero, 1f + bne GRUB_ASM_T4, $zero, 1f nop addiu $t3, $t3, 0xffff digcont: - lb $t5, 0($t3) + lb GRUB_ASM_T5, 0($t3) /* Substract '0' from digit. */ - addiu $t5, $t5, 0xffd0 - bltz $t5, 1f + addiu GRUB_ASM_T5, GRUB_ASM_T5, 0xffd0 + bltz GRUB_ASM_T5, 1f nop - addiu $t4, $t5, 0xfff7 - bgtz $t4, 1f + addiu GRUB_ASM_T4, GRUB_ASM_T5, 0xfff7 + bgtz GRUB_ASM_T4, 1f nop /* Multiply $v0 by 10 with bitshifts. */ sll $v0, $v0, 1 - sll $t4, $v0, 2 - addu $v0, $v0, $t4 - addu $v0, $v0, $t5 + sll GRUB_ASM_T4, $v0, 2 + addu $v0, $v0, GRUB_ASM_T4 + addu $v0, $v0, GRUB_ASM_T5 addiu $t3, $t3, 1 b digcont nop @@ -182,10 +183,10 @@ argdone: b argdone addiu $a1, $a1, 4 do_check: - lb $t4, 0($t7) - beq $t4, $zero, 1f + lb GRUB_ASM_T4, 0($t7) + beq GRUB_ASM_T4, $zero, 1f lb $t3, 0($t6) - bne $t3, $t4, 2f + bne $t3, GRUB_ASM_T4, 2f addiu $t6, $t6, 1 b do_check addiu $t7, $t7, 1 @@ -222,8 +223,8 @@ cmdlinedone: 1: beq $t1, $t3, 2f - lb $t4, 0($t2) - sb $t4, 0($t1) + lb GRUB_ASM_T4, 0($t2) + sb GRUB_ASM_T4, 0($t1) addiu $t1, $t1, 1 b 1b addiu $t2, $t2, 1 diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S index 339ab337e..1fdb58aca 100644 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@ -22,6 +22,7 @@ #include #include #include +#include #define BASE_ADDR 8 @@ -95,8 +96,8 @@ cont: modulesmovcont: beq $t3, $0, modulesmovdone nop - lb $t4, 0($t2) - sb $t4, 0($t1) + lb GRUB_ASM_T4, 0($t2) + sb GRUB_ASM_T4, 0($t1) addiu $t2, $t2, -1 addiu $t1, $t1, -1 b modulesmovcont diff --git a/include/grub/mips/asm.h b/include/grub/mips/asm.h new file mode 100644 index 000000000..ad2f71abe --- /dev/null +++ b/include/grub/mips/asm.h @@ -0,0 +1,11 @@ +#ifndef GRUB_MIPS_ASM_HEADER +#define GRUB_MIPS_ASM_HEADER 1 + +#if defined(_MIPS_SIM) && defined(_ABIN32) && _MIPS_SIM == _ABIN32 +#define GRUB_ASM_T4 $a4 +#define GRUB_ASM_T5 $a5 +#else +#define GRUB_ASM_T4 $t4 +#define GRUB_ASM_T5 $t5 +#endif +#endif