From cfabe05cc6ab88fc7c7a48c9bc0072770b7ad101 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 11 Oct 2015 13:15:50 +0200 Subject: [PATCH] mips: Make setjmp code N32-compliant. --- grub-core/lib/mips/setjmp.S | 51 ++++++++++++++++++++----------------- include/grub/mips/asm.h | 7 +++++ include/grub/mips/setjmp.h | 2 +- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/grub-core/lib/mips/setjmp.S b/grub-core/lib/mips/setjmp.S index f01294518..895235b78 100644 --- a/grub-core/lib/mips/setjmp.S +++ b/grub-core/lib/mips/setjmp.S @@ -18,6 +18,7 @@ #include #include +#include .file "setjmp.S" @@ -29,40 +30,42 @@ GRUB_MOD_LICENSE "GPLv3+" * int grub_setjmp (grub_jmp_buf env) */ FUNCTION(grub_setjmp) - sw $s0, 0($a0) - sw $s1, 4($a0) - sw $s2, 8($a0) - sw $s3, 12($a0) - sw $s4, 16($a0) - sw $s5, 20($a0) - sw $s6, 24($a0) - sw $s7, 28($a0) - sw $s8, 32($a0) - sw $gp, 36($a0) - sw $sp, 40($a0) - sw $ra, 44($a0) + GRUB_ASM_REG_S $s0, 0($a0) + GRUB_ASM_REG_S $s1, 8($a0) + GRUB_ASM_REG_S $s2, 16($a0) + GRUB_ASM_REG_S $s3, 24($a0) + GRUB_ASM_REG_S $s4, 32($a0) + GRUB_ASM_REG_S $s5, 40($a0) + GRUB_ASM_REG_S $s6, 48($a0) + GRUB_ASM_REG_S $s7, 56($a0) + GRUB_ASM_REG_S $s8, 64($a0) + GRUB_ASM_REG_S $gp, 72($a0) + GRUB_ASM_REG_S $sp, 80($a0) + GRUB_ASM_REG_S $ra, 88($a0) move $v0, $zero move $v1, $zero jr $ra + nop /* * int grub_longjmp (grub_jmp_buf env, int val) */ FUNCTION(grub_longjmp) - lw $s0, 0($a0) - lw $s1, 4($a0) - lw $s2, 8($a0) - lw $s3, 12($a0) - lw $s4, 16($a0) - lw $s5, 20($a0) - lw $s6, 24($a0) - lw $s7, 28($a0) - lw $s8, 32($a0) - lw $gp, 36($a0) - lw $sp, 40($a0) - lw $ra, 44($a0) + GRUB_ASM_REG_L $s0, 0($a0) + GRUB_ASM_REG_L $s1, 8($a0) + GRUB_ASM_REG_L $s2, 16($a0) + GRUB_ASM_REG_L $s3, 24($a0) + GRUB_ASM_REG_L $s4, 32($a0) + GRUB_ASM_REG_L $s5, 40($a0) + GRUB_ASM_REG_L $s6, 48($a0) + GRUB_ASM_REG_L $s7, 56($a0) + GRUB_ASM_REG_L $s8, 64($a0) + GRUB_ASM_REG_L $gp, 72($a0) + GRUB_ASM_REG_L $sp, 80($a0) + GRUB_ASM_REG_L $ra, 88($a0) move $v0, $a1 bne $v0, $zero, 1f addiu $v0, $v0, 1 1: move $v1, $zero jr $ra + nop diff --git a/include/grub/mips/asm.h b/include/grub/mips/asm.h index ad2f71abe..4c397f4a0 100644 --- a/include/grub/mips/asm.h +++ b/include/grub/mips/asm.h @@ -4,8 +4,15 @@ #if defined(_MIPS_SIM) && defined(_ABIN32) && _MIPS_SIM == _ABIN32 #define GRUB_ASM_T4 $a4 #define GRUB_ASM_T5 $a5 +#define GRUB_ASM_SZREG 8 +#define GRUB_ASM_REG_S sd +#define GRUB_ASM_REG_L ld #else #define GRUB_ASM_T4 $t4 #define GRUB_ASM_T5 $t5 +#define GRUB_ASM_SZREG 4 +#define GRUB_ASM_REG_S sw +#define GRUB_ASM_REG_L lw #endif + #endif diff --git a/include/grub/mips/setjmp.h b/include/grub/mips/setjmp.h index a99dde9ef..f8f6517ac 100644 --- a/include/grub/mips/setjmp.h +++ b/include/grub/mips/setjmp.h @@ -19,7 +19,7 @@ #ifndef GRUB_SETJMP_CPU_HEADER #define GRUB_SETJMP_CPU_HEADER 1 -typedef unsigned long grub_jmp_buf[12]; +typedef grub_uint64_t grub_jmp_buf[12]; int grub_setjmp (grub_jmp_buf env) RETURNS_TWICE; void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));