mips: Make setjmp code N32-compliant.

This commit is contained in:
Vladimir Serbinenko 2015-10-11 13:15:50 +02:00
parent 285540e448
commit cfabe05cc6
3 changed files with 35 additions and 25 deletions

View file

@ -18,6 +18,7 @@
#include <grub/symbol.h> #include <grub/symbol.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/mips/asm.h>
.file "setjmp.S" .file "setjmp.S"
@ -29,40 +30,42 @@ GRUB_MOD_LICENSE "GPLv3+"
* int grub_setjmp (grub_jmp_buf env) * int grub_setjmp (grub_jmp_buf env)
*/ */
FUNCTION(grub_setjmp) FUNCTION(grub_setjmp)
sw $s0, 0($a0) GRUB_ASM_REG_S $s0, 0($a0)
sw $s1, 4($a0) GRUB_ASM_REG_S $s1, 8($a0)
sw $s2, 8($a0) GRUB_ASM_REG_S $s2, 16($a0)
sw $s3, 12($a0) GRUB_ASM_REG_S $s3, 24($a0)
sw $s4, 16($a0) GRUB_ASM_REG_S $s4, 32($a0)
sw $s5, 20($a0) GRUB_ASM_REG_S $s5, 40($a0)
sw $s6, 24($a0) GRUB_ASM_REG_S $s6, 48($a0)
sw $s7, 28($a0) GRUB_ASM_REG_S $s7, 56($a0)
sw $s8, 32($a0) GRUB_ASM_REG_S $s8, 64($a0)
sw $gp, 36($a0) GRUB_ASM_REG_S $gp, 72($a0)
sw $sp, 40($a0) GRUB_ASM_REG_S $sp, 80($a0)
sw $ra, 44($a0) GRUB_ASM_REG_S $ra, 88($a0)
move $v0, $zero move $v0, $zero
move $v1, $zero move $v1, $zero
jr $ra jr $ra
nop
/* /*
* int grub_longjmp (grub_jmp_buf env, int val) * int grub_longjmp (grub_jmp_buf env, int val)
*/ */
FUNCTION(grub_longjmp) FUNCTION(grub_longjmp)
lw $s0, 0($a0) GRUB_ASM_REG_L $s0, 0($a0)
lw $s1, 4($a0) GRUB_ASM_REG_L $s1, 8($a0)
lw $s2, 8($a0) GRUB_ASM_REG_L $s2, 16($a0)
lw $s3, 12($a0) GRUB_ASM_REG_L $s3, 24($a0)
lw $s4, 16($a0) GRUB_ASM_REG_L $s4, 32($a0)
lw $s5, 20($a0) GRUB_ASM_REG_L $s5, 40($a0)
lw $s6, 24($a0) GRUB_ASM_REG_L $s6, 48($a0)
lw $s7, 28($a0) GRUB_ASM_REG_L $s7, 56($a0)
lw $s8, 32($a0) GRUB_ASM_REG_L $s8, 64($a0)
lw $gp, 36($a0) GRUB_ASM_REG_L $gp, 72($a0)
lw $sp, 40($a0) GRUB_ASM_REG_L $sp, 80($a0)
lw $ra, 44($a0) GRUB_ASM_REG_L $ra, 88($a0)
move $v0, $a1 move $v0, $a1
bne $v0, $zero, 1f bne $v0, $zero, 1f
addiu $v0, $v0, 1 addiu $v0, $v0, 1
1: 1:
move $v1, $zero move $v1, $zero
jr $ra jr $ra
nop

View file

@ -4,8 +4,15 @@
#if defined(_MIPS_SIM) && defined(_ABIN32) && _MIPS_SIM == _ABIN32 #if defined(_MIPS_SIM) && defined(_ABIN32) && _MIPS_SIM == _ABIN32
#define GRUB_ASM_T4 $a4 #define GRUB_ASM_T4 $a4
#define GRUB_ASM_T5 $a5 #define GRUB_ASM_T5 $a5
#define GRUB_ASM_SZREG 8
#define GRUB_ASM_REG_S sd
#define GRUB_ASM_REG_L ld
#else #else
#define GRUB_ASM_T4 $t4 #define GRUB_ASM_T4 $t4
#define GRUB_ASM_T5 $t5 #define GRUB_ASM_T5 $t5
#define GRUB_ASM_SZREG 4
#define GRUB_ASM_REG_S sw
#define GRUB_ASM_REG_L lw
#endif #endif
#endif #endif

View file

@ -19,7 +19,7 @@
#ifndef GRUB_SETJMP_CPU_HEADER #ifndef GRUB_SETJMP_CPU_HEADER
#define GRUB_SETJMP_CPU_HEADER 1 #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; int grub_setjmp (grub_jmp_buf env) RETURNS_TWICE;
void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn)); void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));