automake commit without merge history
This commit is contained in:
parent
265d68cd10
commit
8c41176882
810 changed files with 4980 additions and 2508 deletions
112
grub-core/lib/mips/relocator.c
Normal file
112
grub-core/lib/mips/relocator.c
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/cache.h>
|
||||
|
||||
#include <grub/mips/relocator.h>
|
||||
|
||||
/* Remark: doesn't work with source outside of 4G.
|
||||
Use relocator64 in this case.
|
||||
*/
|
||||
|
||||
extern grub_uint8_t grub_relocator32_forward_start;
|
||||
extern grub_uint8_t grub_relocator32_forward_end;
|
||||
extern grub_uint8_t grub_relocator32_backward_start;
|
||||
extern grub_uint8_t grub_relocator32_backward_end;
|
||||
|
||||
#define REGW_SIZEOF (2 * sizeof (grub_uint32_t))
|
||||
#define JUMP_SIZEOF (2 * sizeof (grub_uint32_t))
|
||||
|
||||
#define RELOCATOR_SRC_SIZEOF(x) (&grub_relocator32_##x##_end \
|
||||
- &grub_relocator32_##x##_start)
|
||||
#define RELOCATOR_SIZEOF(x) (RELOCATOR_SRC_SIZEOF(x) \
|
||||
+ REGW_SIZEOF * (31 + 3) + JUMP_SIZEOF)
|
||||
#define RELOCATOR_ALIGN 16
|
||||
|
||||
#define PREFIX(x) grub_relocator32_ ## x
|
||||
|
||||
static void
|
||||
write_reg (int regn, grub_uint32_t val, void **target)
|
||||
{
|
||||
/* lui $r, (val+0x8000). */
|
||||
*(grub_uint32_t *) *target = ((0x3c00 | regn) << 16) | ((val + 0x8000) >> 16);
|
||||
*target = ((grub_uint32_t *) *target) + 1;
|
||||
/* addiu $r, $r, val. */
|
||||
*(grub_uint32_t *) *target = (((0x2400 | regn << 5 | regn) << 16)
|
||||
| (val & 0xffff));
|
||||
*target = ((grub_uint32_t *) *target) + 1;
|
||||
}
|
||||
|
||||
static void
|
||||
write_jump (int regn, void **target)
|
||||
{
|
||||
/* j $r. */
|
||||
*(grub_uint32_t *) *target = (regn<<21) | 0x8;
|
||||
*target = ((grub_uint32_t *) *target) + 1;
|
||||
/* nop. */
|
||||
*(grub_uint32_t *) *target = 0;
|
||||
*target = ((grub_uint32_t *) *target) + 1;
|
||||
}
|
||||
|
||||
static void
|
||||
write_call_relocator_bw (void *ptr0, void *src, grub_uint32_t dest,
|
||||
grub_size_t size, struct grub_relocator32_state state)
|
||||
{
|
||||
void *ptr = ptr0;
|
||||
int i;
|
||||
write_reg (8, (grub_uint32_t) src, &ptr);
|
||||
write_reg (9, dest, &ptr);
|
||||
write_reg (10, size, &ptr);
|
||||
grub_memcpy (ptr, &grub_relocator32_backward_start,
|
||||
RELOCATOR_SRC_SIZEOF (backward));
|
||||
ptr = (grub_uint8_t *) ptr + RELOCATOR_SRC_SIZEOF (backward);
|
||||
for (i = 1; i < 32; i++)
|
||||
write_reg (i, state.gpr[i], &ptr);
|
||||
write_jump (state.jumpreg, &ptr);
|
||||
grub_arch_sync_caches (ptr0, (grub_uint8_t *) ptr - (grub_uint8_t *) ptr0);
|
||||
grub_dprintf ("relocator", "Backward relocator: about to jump to %p\n", ptr0);
|
||||
((void (*) (void)) ptr0) ();
|
||||
}
|
||||
|
||||
static void
|
||||
write_call_relocator_fw (void *ptr0, void *src, grub_uint32_t dest,
|
||||
grub_size_t size, struct grub_relocator32_state state)
|
||||
{
|
||||
void *ptr = ptr0;
|
||||
int i;
|
||||
write_reg (8, (grub_uint32_t) src, &ptr);
|
||||
write_reg (9, dest, &ptr);
|
||||
write_reg (10, size, &ptr);
|
||||
grub_memcpy (ptr, &grub_relocator32_forward_start,
|
||||
RELOCATOR_SRC_SIZEOF (forward));
|
||||
ptr = (grub_uint8_t *) ptr + RELOCATOR_SRC_SIZEOF (forward);
|
||||
for (i = 1; i < 32; i++)
|
||||
write_reg (i, state.gpr[i], &ptr);
|
||||
write_jump (state.jumpreg, &ptr);
|
||||
grub_arch_sync_caches (ptr0, (grub_uint8_t *) ptr - (grub_uint8_t *) ptr0);
|
||||
grub_dprintf ("relocator", "Forward relocator: about to jump to %p\n", ptr0);
|
||||
((void (*) (void)) ptr0) ();
|
||||
}
|
||||
|
||||
#include "../relocator.c"
|
58
grub-core/lib/mips/relocator_asm.S
Normal file
58
grub-core/lib/mips/relocator_asm.S
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
.p2align 4 /* force 16-byte alignment */
|
||||
|
||||
VARIABLE (grub_relocator32_forward_start)
|
||||
move $a0, $9
|
||||
move $a1, $10
|
||||
|
||||
copycont1:
|
||||
lb $11,0($8)
|
||||
sb $11,0($9)
|
||||
addiu $8, $8, 0x1
|
||||
addiu $9, $9, 0x1
|
||||
addiu $10, $10, 0xffff
|
||||
bne $10, $0, copycont1
|
||||
|
||||
#include "../../kern/mips/cache_flush.S"
|
||||
|
||||
VARIABLE (grub_relocator32_forward_end)
|
||||
|
||||
VARIABLE (grub_relocator32_backward_start)
|
||||
move $a0, $9
|
||||
move $a1, $10
|
||||
|
||||
addu $9, $9, $10
|
||||
addu $8, $8, $10
|
||||
/* Backward movsl is implicitly off-by-one. compensate that. */
|
||||
addiu $9, $9, 0xffff
|
||||
addiu $8, $8, 0xffff
|
||||
copycont2:
|
||||
lb $11,0($8)
|
||||
sb $11,0($9)
|
||||
addiu $8, $8, 0xffff
|
||||
addiu $9, $9, 0xffff
|
||||
addiu $10, 0xffff
|
||||
bne $10, $0, copycont2
|
||||
|
||||
#include "../../kern/mips/cache_flush.S"
|
||||
|
||||
VARIABLE (grub_relocator32_backward_end)
|
65
grub-core/lib/mips/setjmp.S
Normal file
65
grub-core/lib/mips/setjmp.S
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2007,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
.file "setjmp.S"
|
||||
|
||||
.text
|
||||
|
||||
/*
|
||||
* 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)
|
||||
move $v0, $zero
|
||||
move $v1, $zero
|
||||
jr $ra
|
||||
/*
|
||||
* 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)
|
||||
move $v0, $a1
|
||||
bne $v0, $zero, 1f
|
||||
addiu $v0, $v0, 1
|
||||
1:
|
||||
move $v1, $zero
|
||||
jr $ra
|
Loading…
Add table
Add a link
Reference in a new issue